\(\int (a+i a \tan (e+f x)) (A+B \tan (e+f x)) (c-i c \tan (e+f x))^n \, dx\) [665]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [B] (verification not implemented)
   Maxima [B] (verification not implemented)
   Giac [F]
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 39, antiderivative size = 63 \[ \int (a+i a \tan (e+f x)) (A+B \tan (e+f x)) (c-i c \tan (e+f x))^n \, dx=\frac {a (i A+B) (c-i c \tan (e+f x))^n}{f n}-\frac {a B (c-i c \tan (e+f x))^{1+n}}{c f (1+n)} \]

[Out]

a*(I*A+B)*(c-I*c*tan(f*x+e))^n/f/n-a*B*(c-I*c*tan(f*x+e))^(1+n)/c/f/(1+n)

Rubi [A] (verified)

Time = 0.11 (sec) , antiderivative size = 63, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 2, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.051, Rules used = {3669, 45} \[ \int (a+i a \tan (e+f x)) (A+B \tan (e+f x)) (c-i c \tan (e+f x))^n \, dx=\frac {a (B+i A) (c-i c \tan (e+f x))^n}{f n}-\frac {a B (c-i c \tan (e+f x))^{n+1}}{c f (n+1)} \]

[In]

Int[(a + I*a*Tan[e + f*x])*(A + B*Tan[e + f*x])*(c - I*c*Tan[e + f*x])^n,x]

[Out]

(a*(I*A + B)*(c - I*c*Tan[e + f*x])^n)/(f*n) - (a*B*(c - I*c*Tan[e + f*x])^(1 + n))/(c*f*(1 + n))

Rule 45

Int[((a_.) + (b_.)*(x_))^(m_.)*((c_.) + (d_.)*(x_))^(n_.), x_Symbol] :> Int[ExpandIntegrand[(a + b*x)^m*(c + d
*x)^n, x], x] /; FreeQ[{a, b, c, d, n}, x] && NeQ[b*c - a*d, 0] && IGtQ[m, 0] && ( !IntegerQ[n] || (EqQ[c, 0]
&& LeQ[7*m + 4*n + 4, 0]) || LtQ[9*m + 5*(n + 1), 0] || GtQ[m + n + 2, 0])

Rule 3669

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)])*((c_) + (d_.)*tan[(e_
.) + (f_.)*(x_)])^(n_.), x_Symbol] :> Dist[a*(c/f), Subst[Int[(a + b*x)^(m - 1)*(c + d*x)^(n - 1)*(A + B*x), x
], x, Tan[e + f*x]], x] /; FreeQ[{a, b, c, d, e, f, A, B, m, n}, x] && EqQ[b*c + a*d, 0] && EqQ[a^2 + b^2, 0]

Rubi steps \begin{align*} \text {integral}& = \frac {(a c) \text {Subst}\left (\int (A+B x) (c-i c x)^{-1+n} \, dx,x,\tan (e+f x)\right )}{f} \\ & = \frac {(a c) \text {Subst}\left (\int \left ((A-i B) (c-i c x)^{-1+n}+\frac {i B (c-i c x)^n}{c}\right ) \, dx,x,\tan (e+f x)\right )}{f} \\ & = \frac {a (i A+B) (c-i c \tan (e+f x))^n}{f n}-\frac {a B (c-i c \tan (e+f x))^{1+n}}{c f (1+n)} \\ \end{align*}

Mathematica [A] (verified)

Time = 1.00 (sec) , antiderivative size = 50, normalized size of antiderivative = 0.79 \[ \int (a+i a \tan (e+f x)) (A+B \tan (e+f x)) (c-i c \tan (e+f x))^n \, dx=\frac {i a (c-i c \tan (e+f x))^n (A-i B+A n+B n \tan (e+f x))}{f n (1+n)} \]

[In]

Integrate[(a + I*a*Tan[e + f*x])*(A + B*Tan[e + f*x])*(c - I*c*Tan[e + f*x])^n,x]

[Out]

(I*a*(c - I*c*Tan[e + f*x])^n*(A - I*B + A*n + B*n*Tan[e + f*x]))/(f*n*(1 + n))

Maple [A] (verified)

Time = 1.22 (sec) , antiderivative size = 80, normalized size of antiderivative = 1.27

method result size
derivativedivides \(\frac {\left (i A a n +i A a +B a \right ) {\mathrm e}^{n \ln \left (c -i c \tan \left (f x +e \right )\right )}}{f n \left (1+n \right )}+\frac {i B a \tan \left (f x +e \right ) {\mathrm e}^{n \ln \left (c -i c \tan \left (f x +e \right )\right )}}{f \left (1+n \right )}\) \(80\)
default \(\frac {\left (i A a n +i A a +B a \right ) {\mathrm e}^{n \ln \left (c -i c \tan \left (f x +e \right )\right )}}{f n \left (1+n \right )}+\frac {i B a \tan \left (f x +e \right ) {\mathrm e}^{n \ln \left (c -i c \tan \left (f x +e \right )\right )}}{f \left (1+n \right )}\) \(80\)
norman \(\frac {\left (i A a n +i A a +B a \right ) {\mathrm e}^{n \ln \left (c -i c \tan \left (f x +e \right )\right )}}{f n \left (1+n \right )}+\frac {i B a \tan \left (f x +e \right ) {\mathrm e}^{n \ln \left (c -i c \tan \left (f x +e \right )\right )}}{f \left (1+n \right )}\) \(80\)
risch \(\text {Expression too large to display}\) \(1058\)

[In]

int((a+I*a*tan(f*x+e))*(A+B*tan(f*x+e))*(c-I*c*tan(f*x+e))^n,x,method=_RETURNVERBOSE)

[Out]

1/f/n/(1+n)*(I*A*a*n+I*A*a+B*a)*exp(n*ln(c-I*c*tan(f*x+e)))+I*B*a/f/(1+n)*tan(f*x+e)*exp(n*ln(c-I*c*tan(f*x+e)
))

Fricas [A] (verification not implemented)

none

Time = 0.26 (sec) , antiderivative size = 93, normalized size of antiderivative = 1.48 \[ \int (a+i a \tan (e+f x)) (A+B \tan (e+f x)) (c-i c \tan (e+f x))^n \, dx=\frac {{\left ({\left (i \, A - B\right )} a n + {\left (i \, A + B\right )} a + {\left ({\left (i \, A + B\right )} a n + {\left (i \, A + B\right )} a\right )} e^{\left (2 i \, f x + 2 i \, e\right )}\right )} \left (\frac {2 \, c}{e^{\left (2 i \, f x + 2 i \, e\right )} + 1}\right )^{n}}{f n^{2} + f n + {\left (f n^{2} + f n\right )} e^{\left (2 i \, f x + 2 i \, e\right )}} \]

[In]

integrate((a+I*a*tan(f*x+e))*(A+B*tan(f*x+e))*(c-I*c*tan(f*x+e))^n,x, algorithm="fricas")

[Out]

((I*A - B)*a*n + (I*A + B)*a + ((I*A + B)*a*n + (I*A + B)*a)*e^(2*I*f*x + 2*I*e))*(2*c/(e^(2*I*f*x + 2*I*e) +
1))^n/(f*n^2 + f*n + (f*n^2 + f*n)*e^(2*I*f*x + 2*I*e))

Sympy [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 394 vs. \(2 (48) = 96\).

Time = 0.57 (sec) , antiderivative size = 394, normalized size of antiderivative = 6.25 \[ \int (a+i a \tan (e+f x)) (A+B \tan (e+f x)) (c-i c \tan (e+f x))^n \, dx=\begin {cases} x \left (A + B \tan {\left (e \right )}\right ) \left (i a \tan {\left (e \right )} + a\right ) \left (- i c \tan {\left (e \right )} + c\right )^{n} & \text {for}\: f = 0 \\\frac {2 A a}{2 c f \tan {\left (e + f x \right )} + 2 i c f} + \frac {2 i B a f x \tan {\left (e + f x \right )}}{2 c f \tan {\left (e + f x \right )} + 2 i c f} - \frac {2 B a f x}{2 c f \tan {\left (e + f x \right )} + 2 i c f} - \frac {B a \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )} \tan {\left (e + f x \right )}}{2 c f \tan {\left (e + f x \right )} + 2 i c f} - \frac {i B a \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 c f \tan {\left (e + f x \right )} + 2 i c f} - \frac {2 i B a}{2 c f \tan {\left (e + f x \right )} + 2 i c f} & \text {for}\: n = -1 \\A a x + \frac {i A a \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 f} - i B a x + \frac {B a \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 f} + \frac {i B a \tan {\left (e + f x \right )}}{f} & \text {for}\: n = 0 \\\frac {i A a n \left (- i c \tan {\left (e + f x \right )} + c\right )^{n}}{f n^{2} + f n} + \frac {i A a \left (- i c \tan {\left (e + f x \right )} + c\right )^{n}}{f n^{2} + f n} + \frac {i B a n \left (- i c \tan {\left (e + f x \right )} + c\right )^{n} \tan {\left (e + f x \right )}}{f n^{2} + f n} + \frac {B a \left (- i c \tan {\left (e + f x \right )} + c\right )^{n}}{f n^{2} + f n} & \text {otherwise} \end {cases} \]

[In]

integrate((a+I*a*tan(f*x+e))*(A+B*tan(f*x+e))*(c-I*c*tan(f*x+e))**n,x)

[Out]

Piecewise((x*(A + B*tan(e))*(I*a*tan(e) + a)*(-I*c*tan(e) + c)**n, Eq(f, 0)), (2*A*a/(2*c*f*tan(e + f*x) + 2*I
*c*f) + 2*I*B*a*f*x*tan(e + f*x)/(2*c*f*tan(e + f*x) + 2*I*c*f) - 2*B*a*f*x/(2*c*f*tan(e + f*x) + 2*I*c*f) - B
*a*log(tan(e + f*x)**2 + 1)*tan(e + f*x)/(2*c*f*tan(e + f*x) + 2*I*c*f) - I*B*a*log(tan(e + f*x)**2 + 1)/(2*c*
f*tan(e + f*x) + 2*I*c*f) - 2*I*B*a/(2*c*f*tan(e + f*x) + 2*I*c*f), Eq(n, -1)), (A*a*x + I*A*a*log(tan(e + f*x
)**2 + 1)/(2*f) - I*B*a*x + B*a*log(tan(e + f*x)**2 + 1)/(2*f) + I*B*a*tan(e + f*x)/f, Eq(n, 0)), (I*A*a*n*(-I
*c*tan(e + f*x) + c)**n/(f*n**2 + f*n) + I*A*a*(-I*c*tan(e + f*x) + c)**n/(f*n**2 + f*n) + I*B*a*n*(-I*c*tan(e
 + f*x) + c)**n*tan(e + f*x)/(f*n**2 + f*n) + B*a*(-I*c*tan(e + f*x) + c)**n/(f*n**2 + f*n), True))

Maxima [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 311 vs. \(2 (57) = 114\).

Time = 0.45 (sec) , antiderivative size = 311, normalized size of antiderivative = 4.94 \[ \int (a+i a \tan (e+f x)) (A+B \tan (e+f x)) (c-i c \tan (e+f x))^n \, dx=\frac {{\left ({\left (A - i \, B\right )} a c^{n} n + {\left (A - i \, B\right )} a c^{n}\right )} 2^{n} \cos \left (-2 \, f x + n \arctan \left (\sin \left (2 \, f x + 2 \, e\right ), \cos \left (2 \, f x + 2 \, e\right ) + 1\right ) - 2 \, e\right ) + {\left ({\left (A + i \, B\right )} a c^{n} n + {\left (A - i \, B\right )} a c^{n}\right )} 2^{n} \cos \left (n \arctan \left (\sin \left (2 \, f x + 2 \, e\right ), \cos \left (2 \, f x + 2 \, e\right ) + 1\right )\right ) - {\left ({\left (i \, A + B\right )} a c^{n} n + {\left (i \, A + B\right )} a c^{n}\right )} 2^{n} \sin \left (-2 \, f x + n \arctan \left (\sin \left (2 \, f x + 2 \, e\right ), \cos \left (2 \, f x + 2 \, e\right ) + 1\right ) - 2 \, e\right ) - {\left ({\left (i \, A - B\right )} a c^{n} n + {\left (i \, A + B\right )} a c^{n}\right )} 2^{n} \sin \left (n \arctan \left (\sin \left (2 \, f x + 2 \, e\right ), \cos \left (2 \, f x + 2 \, e\right ) + 1\right )\right )}{{\left (-i \, n^{2} + {\left (-i \, n^{2} - i \, n\right )} \cos \left (2 \, f x + 2 \, e\right ) + {\left (n^{2} + n\right )} \sin \left (2 \, f x + 2 \, e\right ) - i \, n\right )} {\left (\cos \left (2 \, f x + 2 \, e\right )^{2} + \sin \left (2 \, f x + 2 \, e\right )^{2} + 2 \, \cos \left (2 \, f x + 2 \, e\right ) + 1\right )}^{\frac {1}{2} \, n} f} \]

[In]

integrate((a+I*a*tan(f*x+e))*(A+B*tan(f*x+e))*(c-I*c*tan(f*x+e))^n,x, algorithm="maxima")

[Out]

(((A - I*B)*a*c^n*n + (A - I*B)*a*c^n)*2^n*cos(-2*f*x + n*arctan2(sin(2*f*x + 2*e), cos(2*f*x + 2*e) + 1) - 2*
e) + ((A + I*B)*a*c^n*n + (A - I*B)*a*c^n)*2^n*cos(n*arctan2(sin(2*f*x + 2*e), cos(2*f*x + 2*e) + 1)) - ((I*A
+ B)*a*c^n*n + (I*A + B)*a*c^n)*2^n*sin(-2*f*x + n*arctan2(sin(2*f*x + 2*e), cos(2*f*x + 2*e) + 1) - 2*e) - ((
I*A - B)*a*c^n*n + (I*A + B)*a*c^n)*2^n*sin(n*arctan2(sin(2*f*x + 2*e), cos(2*f*x + 2*e) + 1)))/((-I*n^2 + (-I
*n^2 - I*n)*cos(2*f*x + 2*e) + (n^2 + n)*sin(2*f*x + 2*e) - I*n)*(cos(2*f*x + 2*e)^2 + sin(2*f*x + 2*e)^2 + 2*
cos(2*f*x + 2*e) + 1)^(1/2*n)*f)

Giac [F]

\[ \int (a+i a \tan (e+f x)) (A+B \tan (e+f x)) (c-i c \tan (e+f x))^n \, dx=\int { {\left (B \tan \left (f x + e\right ) + A\right )} {\left (i \, a \tan \left (f x + e\right ) + a\right )} {\left (-i \, c \tan \left (f x + e\right ) + c\right )}^{n} \,d x } \]

[In]

integrate((a+I*a*tan(f*x+e))*(A+B*tan(f*x+e))*(c-I*c*tan(f*x+e))^n,x, algorithm="giac")

[Out]

integrate((B*tan(f*x + e) + A)*(I*a*tan(f*x + e) + a)*(-I*c*tan(f*x + e) + c)^n, x)

Mupad [B] (verification not implemented)

Time = 1.20 (sec) , antiderivative size = 128, normalized size of antiderivative = 2.03 \[ \int (a+i a \tan (e+f x)) (A+B \tan (e+f x)) (c-i c \tan (e+f x))^n \, dx=-\frac {\left (\cos \left (e+f\,x\right )-\sin \left (e+f\,x\right )\,1{}\mathrm {i}\right )\,{\left (c-\frac {c\,\sin \left (e+f\,x\right )\,1{}\mathrm {i}}{\cos \left (e+f\,x\right )}\right )}^n\,\left (\frac {a\,\left (A-B\,1{}\mathrm {i}+A\,n+B\,n\,1{}\mathrm {i}\right )}{f\,n\,\left (n\,1{}\mathrm {i}+1{}\mathrm {i}\right )}+\frac {a\,\left (A-B\,1{}\mathrm {i}\right )\,\left (\cos \left (2\,e+2\,f\,x\right )+\sin \left (2\,e+2\,f\,x\right )\,1{}\mathrm {i}\right )\,\left (n+1\right )}{f\,n\,\left (n\,1{}\mathrm {i}+1{}\mathrm {i}\right )}\right )}{2\,\cos \left (e+f\,x\right )} \]

[In]

int((A + B*tan(e + f*x))*(a + a*tan(e + f*x)*1i)*(c - c*tan(e + f*x)*1i)^n,x)

[Out]

-((cos(e + f*x) - sin(e + f*x)*1i)*(c - (c*sin(e + f*x)*1i)/cos(e + f*x))^n*((a*(A - B*1i + A*n + B*n*1i))/(f*
n*(n*1i + 1i)) + (a*(A - B*1i)*(cos(2*e + 2*f*x) + sin(2*e + 2*f*x)*1i)*(n + 1))/(f*n*(n*1i + 1i))))/(2*cos(e
+ f*x))